/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, useTheme,} from "customize-easy-ui-component";
import { ReportViewProps, } from "../../common/base";
import {末尾链接, 落款单位地址,} from "../../common/rarelyVary";
import {检验结论报告, 适装介质列表,} from "./repView";
import {useSubRepMain} from "../../hook/useSubRepMain";
import {useRepMenuDirItems} from "../../hook/useMainRepUrlOr";
import {宏观检验报告} from "./viewMacr";
import {资料审查报告} from "./viewReview";
import {注意事项Tank,  首页设备概况Tank} from "./rarelyVary";
import {VsProjects默认} from "./editor";
import {useItemsMapPressure} from "../../common/pressure";
import {安全附件检验} from "./viewAcces";
import {CertificatePage} from "./viewCert";
import {目录页VS} from "../rarelyVary";
import {ReportFirstPageHeadAllNmbbm} from "../../contain/rarelyVary";

export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
    const theme= useTheme();
    const [mapFxian]=useItemsMapPressure({ projects:orc.Projects });
    const [rootMenu]=useRepMenuDirItems(VsProjects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
    const [renderThickm]= useSubRepMain("cm/thickm", {nestMd:'THICK_MS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderPressure]= useSubRepMain("cm/pressure", {nestMd:'PRSRE_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderGasproof ]= useSubRepMain("cm/gasproof", {nestMd:'GASPR_TS',orc, repId:repId!, rep, NestMbVer:1});
  return (
    <React.Fragment>
        {rootMenu}
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
          { orc?.检验结论==='符合' &&
                <CertificatePage orc={orc} rep={rep}/>
          }
          <div css={{
              display: 'flex',
              flexDirection: 'column',
              justifyContent: 'space-between',
              "@media print": {height:'100vh', pageBreakInside: 'avoid',}
          }}>
                {ReportFirstPageHeadAllNmbbm({theme, rep, mbbm: 'FJB/TM-1007-1-0-2022'})}
                <div>
                    <Text variant="h3" css={{
                        textAlign: 'center',
                        "@media (min-width:690px),print and (min-width:538px)": {
                            fontSize: theme.fontSizes[6],
                    }} }>
                     道路运输液体危险货物罐式车辆<br/>常压容器（罐体）定期检验报告
                    </Text>
                    <br css={{"@media not print": {display: 'none'}}}/>
                    <Text variant="h5" css={{
                        textAlign: 'center',
                    }}> （ FJB/RC 1038-2022 ）
                    </Text>
                </div>
                <div>
                    {首页设备概况Tank({theme, orc, rep})}
                </div>
                <div css={{textAlign: 'center', "@media print": {pageBreakInside: 'avoid'}}}>
                    {落款单位地址}
                </div>
           </div>

            {注意事项Tank({
                rep,
                comply: '书适用于道路运输液体危险货物罐式车辆常压容器（罐体）定期检验'
            })}

            {目录页VS({theme, orc, rep, suffix: false})}
            {检验结论报告({theme, orc, rep})}
            {资料审查报告({theme, orc, rep})}

            {适装介质列表({theme, orc, rep})}
            {宏观检验报告({theme, orc, rep})}

            {mapFxian.get('壁厚测定报告')?.do && <>
                {renderThickm}
               </>
            }
            {mapFxian.get('附件检验报告')?.do &&
                安全附件检验({theme, orc, rep})
            }

            {mapFxian.get('罐体盛水试验报告')?.do && <>
                <h2>模板还未知的分项</h2>
            </>}
            {mapFxian.get('罐体气密性试验报告')?.do && <>
                {renderGasproof}
            </>}
            {mapFxian.get('罐体耐压试验报告')?.do && <>
                {renderPressure}
            </>}
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}
